package com.ygk.bluepath.member.View;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;

import com.ygk.bluepath.R;
import com.ygk.bluepath.core.BActivity;
import com.ygk.bluepath.core.BFragment;
import com.ygk.bluepath.member.Presenter.RegisterPresenter;
import com.ygk.bluepath.member.Presenter.RegisterPresenterFragmentTwo;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by Handreace on 16-7-12.
 */
public class RegisterActivity extends BActivity implements RegisterView {

    private RegisterPresenter registerPresenter;
    private List<BFragment> mFragments;
    private BFragment oldFragment;
    private FragmentTransaction transaction;

    private int CurFra = 0;

    private String mobileNum = "";//手机号
    private String code = "";//验证码
    private String realName = "";//真实姓名
    private String identificationNum = "";//身份证号码
    private String password = "";//密码

    private String identificationFrontUrl = "";//身份证正面
    private String identificationBackUrl = "";//身份证背面
    private String identificationFaceUrl = "";//身份证半身照

    private String carNum = "";//车牌号

    private String vehicleLicenseFrontUrl = "";//行驶证正本
    private String vehicleLicenseBackUrl = "";//行驶证副本
    private String vehicleLicensePeopleUrl = "";//行驶证人车合影


    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.activity_register);
        init();
    }

    private void init() {
        registerPresenter = new RegisterPresenter(this, this);

        mFragments = new LinkedList<BFragment>();
        mFragments.add(new RegisterFragmentOne());
        mFragments.add(new RegisterFragmentTwo());
        mFragments.add(new RegisterFragmentThree());

        if (mFragments.size() != 0) {
            oldFragment = new BFragment();
            changeFragment(0);
        }
    }

    public void changeFragment(int i) {
        transaction = getSupportFragmentManager().beginTransaction();
        if (mFragments.get(i) != oldFragment) {
            if (!mFragments.get(i).isAdded()) {
                transaction.hide(oldFragment)
                        .add(R.id.flyt_container, mFragments.get(i))
                        .show(mFragments.get(i)).commit();
            } else {
                transaction.hide(oldFragment).show(mFragments.get(i)).commit();
            }

            oldFragment = mFragments.get(i);
            /*
			 * getSupportFragmentManager().beginTransaction()
			 * .replace(R.id.flyt_container, fragment).commit();
			 */
        }

        CurFra = i;

    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (CurFra == 1) {
            ((RegisterFragmentTwo) oldFragment).onActivityResult(requestCode, resultCode, data);
        } else if (CurFra == 2) {
            ((RegisterFragmentThree) oldFragment).onActivityResult(requestCode, resultCode, data);
        }
    }


    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getIdentificationNum() {
        return identificationNum;
    }

    public void setIdentificationNum(String identificationNum) {
        this.identificationNum = identificationNum;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMobileNum() {
        return mobileNum;
    }

    public void setMobileNum(String mobileNum) {
        this.mobileNum = mobileNum;
    }

    public String getIdentificationFaceUrl() {
        return identificationFaceUrl;
    }

    public void setIdentificationFaceUrl(String identificationFaceUrl) {
        this.identificationFaceUrl = identificationFaceUrl;
    }

    public String getIdentificationBackUrl() {
        return identificationBackUrl;
    }

    public void setIdentificationBackUrl(String identificationBackUrl) {
        this.identificationBackUrl = identificationBackUrl;
    }

    public String getIdentificationFrontUrl() {
        return identificationFrontUrl;
    }

    public void setIdentificationFrontUrl(String identificationFrontUrl) {
        this.identificationFrontUrl = identificationFrontUrl;
    }

    public String getVehicleLicensePeopleUrl() {
        return vehicleLicensePeopleUrl;
    }

    public void setVehicleLicensePeopleUrl(String vehicleLicensePeopleUrl) {
        this.vehicleLicensePeopleUrl = vehicleLicensePeopleUrl;
    }

    public String getVehicleLicenseBackUrl() {
        return vehicleLicenseBackUrl;
    }

    public void setVehicleLicenseBackUrl(String vehicleLicenseBackUrl) {
        this.vehicleLicenseBackUrl = vehicleLicenseBackUrl;
    }

    public String getVehicleLicenseFrontUrl() {
        return vehicleLicenseFrontUrl;
    }

    public void setVehicleLicenseFrontUrl(String vehicleLicenseFrontUrl) {
        this.vehicleLicenseFrontUrl = vehicleLicenseFrontUrl;
    }

    public String getCarNum() {
        return carNum;
    }

    public void setCarNum(String carNum) {
        this.carNum = carNum;
    }
}
